# distutils: language=c++
from py4godot.classes.core cimport *
from py4godot.classes.Object cimport *
cimport py4godot.utils.utils as utils

cdef dict types_dict = {
int:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_INT,
str:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_STRING,
type(True):GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_BOOL,
float:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_FLOAT,
Object:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_OBJECT,
Vector4:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_VECTOR4,
PackedColorArray:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY,
Vector2i:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_VECTOR2I,
Vector3i:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_VECTOR3I,
Quaternion:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_QUATERNION,
Callable:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_CALLABLE,
PackedVector2Array:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY,
Vector4i:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_VECTOR4I,
Array:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_ARRAY,
PackedByteArray:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PACKED_BYTE_ARRAY,
AABB:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_AABB,
Transform3D:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_TRANSFORM3D,
Transform2D:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_TRANSFORM2D,
Rect2i:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_RECT2I,
PackedFloat64Array:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY,
Dictionary:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_DICTIONARY,
PackedStringArray:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY,
Plane:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PLANE,
PackedInt64Array:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PACKED_INT64_ARRAY,
Signal:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_SIGNAL,
PackedFloat32Array:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT32_ARRAY,
Rect2:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_RECT2,
Vector2:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_VECTOR2,
NodePath:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_NODE_PATH,
Color:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_COLOR,
StringName:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_STRING_NAME,
RID:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_RID,
Projection:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PROJECTION,
PackedInt32Array:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PACKED_INT32_ARRAY,
Vector3:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_VECTOR3,
PackedVector3Array:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY,
Basis:GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_BASIS,
}

cdef object convert_val(object val):
    if(type(val) == str):
        return utils.py_c_string_to_string(val.encode("utf-8"))
    return val

cdef GDExtensionVariantType get_variant_type(object type_):
    if(type_ in types_dict.keys()):
        return types_dict[type_]
    print_error("couldn't find type:")
    print_error(str(type_).encode("utf-8"))
    return GDExtensionVariantType.GDEXTENSION_VARIANT_TYPE_NIL
